package org.linphone;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.support.annotation.Nullable;
import android.view.KeyEvent;
import android.widget.Toast;

import org.linphone.app.MyApplication;


public class BaseActivity extends Activity {
    @Override
    public void onCreate(@Nullable Bundle savedInstanceState, @Nullable PersistableBundle persistentState) {
        super.onCreate(savedInstanceState, persistentState);
    }

    @Override
    public boolean dispatchKeyEvent(KeyEvent event) {
        if(event.getKeyCode()== KeyEvent.KEYCODE_F2){
            try{
                Intent intent = new Intent();
                intent.setClassName("com.sxygsj.newsubmain",
                        "com.sxygsj.newsubmain.activities.MainActivity");
                this.startActivity(intent);

            }catch (Exception e){
                System.err.println(Toast.makeText(getApplicationContext(), "未安装主应用模块", Toast.LENGTH_SHORT));
            }
            //推出当前应用的所有activity
            MyApplication.exit();
            return true;
        }

        return super.dispatchKeyEvent(event);
    }
}
